<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                                                                                                             |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: shaoshuai@clcw.com.cn  Blog:http://blog.csdn.net/samxx8        |
// +------------------------------------------------------------------------+
//
namespace AuctionCore\AuctionOrder;

use AuctionCore\CarDealer\Dealer;

class AutoPrice
{
    
    public function price_queue($order_id, $p)
    {
        $price_queue_count = M('auto_bidding')->alias('a')
        ->join(C('DB_PREFIX') . 'car_dealer AS c ON a.dealer_id = c.dealer_id')
        ->where('a.order_id ='.$order_id)->count();
        
        
        $price_queue_list = M('auto_bidding')->alias('a')
            ->field('a.ab_id,a.limit_price,a.createtime,a.status,c.contact_person,du.uid')
            ->join(C('DB_PREFIX') . 'car_dealer AS c ON a.dealer_id = c.dealer_id')
            ->join(C('DB_PREFIX') . "dealer_user as du ON c.dealer_id = du.dealer_id")
            ->where('a.order_id ='.$order_id)
            ->order('a.ab_id asc')
            ->page($p, 10)->select();
        $dealer = new Dealer();
        if(!empty($price_queue_list)){
            $price_queue_list= $dealer->get_contact_mobile_byAntNest($price_queue_list);
        }
        $Page = new \AuctionCore\Common\AjaxPage($price_queue_count, 10, "getPriceQueue");
        $Page->setConfig('theme', " %totalRow% %header% %nowPage%/%totalPage% 页 %first% %upPage% %prePage% %linkPage% %downPage% %nextPage% %end% %jumpform%");
        $show = $Page->show(); // 分页显示输出
        
        return array('list'=>$price_queue_list, 'page'=>$show);
        
    }

    public function price_history($order_id, $p)
    {
        $price_history_count = M('auto_bidding_log')->alias('abl')
        ->join(C('DB_PREFIX') . 'auto_bidding AS ab ON abl.ab_id = ab.ab_id')
        ->join(C('DB_PREFIX') . 'car_dealer AS cd ON ab.dealer_id = cd.dealer_id')
        ->where("abl.order_id = '$order_id'")
        ->count();
        
        $price_history_list = M('auto_bidding_log')->alias('abl')
            ->field('abl.abl_id,abl.price,abl.result,abl.remark,abl.createtime,ab.ab_id,ab.limit_price,cd.contact_person,du.uid')
            ->join(C('DB_PREFIX') . 'auto_bidding AS ab ON abl.ab_id = ab.ab_id')
            ->join(C('DB_PREFIX') . 'car_dealer AS cd ON ab.dealer_id = cd.dealer_id')
            ->join(C('DB_PREFIX') . 'dealer_user as du ON cd.dealer_id = du.dealer_id')
            ->where("abl.order_id = '$order_id'")
            ->order('abl.abl_id asc')
            ->page($p, 10)->select();
        $dealer = new Dealer();
        if(!empty($price_history_list)){
            $price_history_list = $dealer->get_contact_mobile_byAntNest($price_history_list);
        }
        $Page = new \AuctionCore\Common\AjaxPage($price_history_count, 10, "getPriceHistory");
        $Page->setConfig('theme', " %totalRow% %header% %nowPage%/%totalPage% 页 %first% %upPage% %prePage% %linkPage% %downPage% %nextPage% %end% %jumpform%");
        $show = $Page->show(); // 分页显示输出

        return array('list'=>$price_history_list, 'page'=>$show);
        
    }
    
    
    
}

